package com.ease.framework.workbench.spi {

	import com.ease.common.models.IModel;

	import mx.core.Container;
	import mx.core.UIComponent;
	import mx.validators.ValidationResult;

	/**
	 * 默认实现
	 *
	 *
	 */
	public class AbstractControlCreator implements IControlCreator {

		private var _title:String;
		private var _model:IModel;
		private var _context:IValueRepository;
		private var _currentControl:UIComponent;

		public function AbstractControlCreator() {
		}

		public function get title():String {
			return _title;
		}

		public function set title(r_Title:String):void {
			_title = r_Title;
		}

		public function get context():IValueRepository {
			return _context;
		}

		public function set context(r_ValueRepository:IValueRepository):void {
			_context = r_ValueRepository;
		}

		public function get currentControl():UIComponent {
			return _currentControl;
		}

		public function get model():IModel {
			return _model;
		}

		public function set model(mo:IModel):void {
			_model = mo;
		}

		public final function createComponent(parent:Container):UIComponent {
			if(_currentControl == null) {
				_currentControl = doCreateComponent()
			}
			Object(_currentControl).context = _context;
			parent.addChild(_currentControl);
			return _currentControl;
		}

		public function doCreateComponent():UIComponent {
			//子类实现
			return null;
		}

		public function load():void {
			//子类实现
		}

		public function save():void {
			//子类实现
		}

		public function validate():ValidationResult {
			//子类实现
			return null;
		}
	}
}